

<!-- Right side column. Contains the navbar and content of the page -->
<aside class="right-side">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1> Add User</h1>
        <ol class="breadcrumb">
            <li><a href="<?php echo base_url(); ?>dashboard"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="<?php echo base_url(); ?>user">User View</a></li>
            <li class="active">Add User</li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <!-- left column -->
            <div class="col-md-12">
                <!-- general form elements -->
                <div class="box box-primary">
                    <!-- form start -->
                    <!--<form role="form" name="registration" method="POST" action="<?php echo base_url(); ?>user/saveUser">-->
                    <form role="form" name="registration" method="post" action="">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="name">Name</label>
                                <input type="text" class="form-control" id="name" placeholder="Enter Name" name="name" value="<?php echo set_value('name'); ?>">
                                <?php echo form_error('name'); ?>
                            </div>
                            <div class="form-group">
                                <label for="username">Username</label>
                                <input type="text" class="form-control" id="username" placeholder="username" name="username" value="<?php echo set_value('username'); ?>" onblur="user_check(this.value);"><div id="Msg"></div>
                                <?php echo form_error('username'); ?>
                            </div>
                            <div class="form-group">
                                <label for="email">Email address</label>
                                <input type="email" class="form-control" id="email" placeholder="Enter email" name="email" value="<?php echo set_value('email'); ?>">
                                <?php echo form_error('email'); ?>
                            </div>
                            <div class="form-group">
                                <label for="password">Password</label>
                                <input type="password" class="form-control" id="password" placeholder="Password" name="password">
                                <?php echo form_error('password'); ?>
                            </div>

                        </div><!-- /.box-body -->

                        <div class="box-footer">
                            <button type="submit" id="submit" class="btn btn-primary" name="submit" value="Add">addUser</button>
                        </div>
                    </form>
                </div><!-- /.box -->
                <script>
                    function user_check(val)
                    {
                        if (val != '')
                        {

                            var str = 'user=' + val;
                            $.ajax({
                                type: "POST",
                                url: "<?php echo base_url(); ?>user/check_User",
                                data: str,
                                success: function(data)
                                {
                                    //alert(data);
                                    if (data == 0)
                                    {
                                        $("div#Msg").html("<span class='succ'>User Name Available.</span>");
                                    }
                                    else
                                    {
                                        document.getElementsByName("username").value = '';
                                        $("div#Msg").html("<span class='err'>User Name already exist.</span>");
                                    }
                                }
                            });
                        }

                    }

                </script>


